package com.cheng.mybatis.service.impl;

import com.cheng.mybatis.dao.UserMapper;
import com.cheng.mybatis.entity.User;
import com.cheng.mybatis.service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {

    private final UserMapper userMapper;

    public UserServiceImpl(UserMapper userMapper) {
        this.userMapper = userMapper;
    }

    @Override
    public int addUser(User user) {
        return userMapper.insertUser(user);
    }

    @Override
    public int removeUser(int id) {
        return userMapper.delectUser(id);
    }

    @Override
    public int modifyUser(User user) {
        return userMapper.updateUser(user);
    }

    @Override
    public User findUserByid(int id) {
        return userMapper.queryUserById(id);
    }

    @Override
    public List<User> findAllUser() {
        return userMapper.queryAllUser();
    }
}
